﻿using DG.Tweening;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;

namespace Gp.Scripts.Core.GUI {

    public class PropertyInfo {
        public string Label;
        public int Value;
        public string Description;

        public DrawMode Mode;
        public PropertyInfo(string label, int value, string description) {
            Label = label;
            Value = value;
            Description = description;
            Mode = DrawMode.String;
        }

        public PropertyInfo(string label, int value, string description, DrawMode mode) {
            Label = label;
            Value = value;
            Description = description;
            Mode = mode;
        }


        public enum DrawMode {
            String,
            Segment,
            ProgressBar,
        }
    }
    
    
    public class PropertyUIEntry : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler {
        [FormerlySerializedAs("titleTxt")] public TMP_Text labelTxt;
        public TMP_Text valueTxt;
        public TMP_Text description;
        public CanvasGroup tooltips;


        public void Draw(PropertyInfo info) {
            labelTxt.text = info.Label;
            description.text = info.Description;
            valueTxt.text = info.Value.ToString();
        }
        
        
        
        
        public void OnPointerEnter(PointerEventData eventData) {
            if (tooltips == null) return;
            tooltips.DOFade(1, .2f);
            tooltips.transform.DOScale(1, .2f);
        }


        public void OnPointerExit(PointerEventData eventData) {
            if (tooltips == null) return;
            tooltips.DOFade(0, .2f);
            tooltips.transform.DOScale(.2f, 0);
        }
    }
}